<template>
  <div class="dds">
    <input
      v-model="codeInput"
      ref="codeInput"
      @blur="focusInput"
      :autofocus="true"
      clearable
      @change="handleChange"
    />
  </div>
</template>

<script>
export default {
  data() {
    return {
      codeInput: "",
      inputvalue: "",
      disableBlur: true,
    };
  },
  mounted() {
    this.focusInput();
  },
  methods: {
    // input框永久性聚焦
    focusInput() {
     if(this.disableBlur){
      setTimeout(this.$refs["codeInput"].focus(),0)
     }
    },
    handleChange() {
      this.$emit("update", this.codeInput);
      console.log(this.codeInput);
      this.codeInput = "";
    },
  }
};
</script>

<style lang="scss" scoped>
.dds{
    position: relative;
}
input {
    position:absolute;
    // left: -200rem;
}
</style>